 
package com.zdkj.subway.rca.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.fill.FillConfig;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zdkj.common.core.exceltools.MultipartFileToFile;
import com.zdkj.subway.rca.dto.out.SwCkOthenTicketRevenueManagementDTO;
import com.zdkj.subway.rca.entity.SwCkOthenTicketRevenueManagement;
import com.zdkj.subway.rca.entity.SwCkOthenTicketRevenueManagementLog;
import com.zdkj.subway.rca.mapper.SwCkOthenTicketRevenueManagementLogMapper;
import com.zdkj.subway.rca.service.SwCkOthenTicketRevenueManagementLogService;
import com.zdkj.subway.rca.service.SwCkOthenTicketRevenueManagementService;
import com.zdkj.subway.rca.service.SwCkOthenTicketRevenueManagementTmpService;
import com.zdkj.subway.rca.util.LocalDateConverter;
import com.zdkj.subway.rca.util.LocalDateTimeConverter;
import com.zdkj.subway.rca.util.MyDateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;

/**
 * 其他运营商机场城际票务收入管理日志表
 *
 * @author stw
 * @date 2020-10-31 08:14:50
 */
@Service
public class SwCkOthenTicketRevenueManagementLogServiceImpl extends ServiceImpl<SwCkOthenTicketRevenueManagementLogMapper, SwCkOthenTicketRevenueManagementLog> implements SwCkOthenTicketRevenueManagementLogService {
    private static final Logger LOGGER = LoggerFactory.getLogger(SwCkOthenTicketRevenueManagementLogServiceImpl.class);
    @Autowired
    private SwCkOthenTicketRevenueManagementTmpService swCkOthenTicketRevenueManagementTmpService;
    @Autowired
    private SwCkOthenTicketRevenueManagementService swCkOthenTicketRevenueManagementService;

    @Override
    public void exportTamplates( HttpServletResponse response) {
        String  verifyConfirmName = "其他运营商机场城际票务收入管理";
        String  tableName = "sw_ck_othen_ticket_revenue_management";

        BufferedInputStream br = null;
        OutputStream out = null;
        try {
            response.reset(); // 非常重要
            response.setContentType("application/vnd.ms-excel");
            response.setCharacterEncoding("utf-8");
            final String fileName = URLEncoder.encode(verifyConfirmName, "UTF-8");
            response.setHeader("Content-disposition", "attachment;filename=" + fileName + System.currentTimeMillis() + ".xls");

            br =  new BufferedInputStream(this.getClass().getResourceAsStream("/static/excel/template/import/" + tableName + ".xls"));

            byte[] buf = new byte[1024];
            int len = 0;

            out = response.getOutputStream();
            while ((len = br.read(buf)) > 0) {
                out.write(buf, 0, len);
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if(out != null) {
                try {
                    out.close();
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                }
            }
            if(br != null){
                try {
                    br.close();
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                }
            }
        }
    }

    @Override
    public Boolean saveBatchWithExcel(MultipartFile file) throws Exception {

        File excelFile = MultipartFileToFile.multipartFileToFile(file);
        swCkOthenTicketRevenueManagementTmpService.saveBatchWithExcel(excelFile);

        return true;
    }

    @Override
    public void export(String startDate, String endDate, HttpServletResponse response) {
        List<SwCkOthenTicketRevenueManagement> records = swCkOthenTicketRevenueManagementService.list(Wrappers.<SwCkOthenTicketRevenueManagement>lambdaQuery()
                .between(SwCkOthenTicketRevenueManagement::getStatisticsDate, startDate, endDate)
                .orderByAsc(SwCkOthenTicketRevenueManagement::getStatisticsDate));
        BigDecimal decimal100 = new BigDecimal("100");
        List<SwCkOthenTicketRevenueManagementDTO> list = new ArrayList<>();
        if(CollectionUtil.isNotEmpty(records)){
            SwCkOthenTicketRevenueManagementDTO sumMoney = new SwCkOthenTicketRevenueManagementDTO();
            sumMoney.setStatisticsDate("合计");
            for (SwCkOthenTicketRevenueManagement record : records) {
                SwCkOthenTicketRevenueManagementDTO revenueManagementDTO = new SwCkOthenTicketRevenueManagementDTO();
                revenueManagementDTO.setStatisticsDate(MyDateUtil.LocalDateTurnString(record.getStatisticsDate()));
                revenueManagementDTO.setTvmOneTicketCash(transform(record.getTvmOneTicketCash()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setTvmOneTicketAlipay(transform(record.getTvmOneTicketAlipay()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setTvmOneTicketWechat(transform(record.getTvmOneTicketWechat()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setTvmOneTicketXbank(transform(record.getTvmOneTicketXbank()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setTvmSubTotal(transform(record.getTvmSubTotal()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
               
				revenueManagementDTO.setBomOneTicketCash(transform(record.getBomOneTicketCash()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
				revenueManagementDTO.setBomOnePosAmount(transform(record.getBomOnePosAmount()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setBomOneTicketPos(transform(record.getBomOneTicketPos()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setBomOneTicketWechat(transform(record.getBomOneTicketWechat()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setBomSubTotal(transform(record.getBomSubTotal()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
               
				revenueManagementDTO.setPrefabricatedTicketAmount(transform(record.getPrefabricatedTicketAmount()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
				revenueManagementDTO.setPrefabricatedTicketPosAmount(transform(record.getPrefabricatedTicketPosAmount()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
               
				revenueManagementDTO.setEmergencyTicketAmount(transform(record.getEmergencyTicketAmount()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setTicketCounting(transform(record.getTicketCounting()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                
				revenueManagementDTO.setDailyTicketCash(transform(record.getDailyTicketCash()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
				revenueManagementDTO.setDailyTicketPosAmount(transform(record.getDailyTicketPosAmount()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setDailyTicketPos(transform(record.getDailyTicketPos()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setDailyTicketWechat(transform(record.getDailyTicketWechat()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setDailySubTotal(transform(record.getDailySubTotal()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                
				revenueManagementDTO.setCommemorativeTicketCash(transform(record.getCommemorativeTicketCash()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
				revenueManagementDTO.setCommemorativeTicketPosAmount(transform(record.getCommemorativeTicketPosAmount()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setCommemorativeTicketPos(transform(record.getCommemorativeTicketPos()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setCommemorativeTicketWechat(transform(record.getCommemorativeTicketWechat()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setCommemorativeTicketSubTotal(transform(record.getCommemorativeTicketSubTotal()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setAppCommemorativeTicketWechat(transform(record.getAppCommemorativeTicketWechat()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
               
				revenueManagementDTO.setCatTicketCash(transform(record.getCatTicketCash()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
				revenueManagementDTO.setCatTicketPosAmount(transform(record.getCatTicketPosAmount()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setCatTicketPos(transform(record.getCatTicketPos()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setCatTicketWechat(transform(record.getCatTicketWechat()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setCatTicketTvmsimAlipay(transform(record.getCatTicketTvmsimAlipay()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setCatTicketTvmsimWechat(transform(record.getCatTicketTvmsimWechat()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setCatTicketTvmsimXbank(transform(record.getCatTicketTvmsimXbank()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setCatSubTotal(transform(record.getCatSubTotal()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setCatTicketPayCard(transform(record.getCatTicketPayCard()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setOnlineTicketSales(transform(record.getOnlineTicketSales()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setQrCodeTicketAlipay(transform(record.getQrCodeTicketAlipay()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setQrCodeTicketWechat(transform(record.getQrCodeTicketWechat()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setQrCodeTicketUnionpay(transform(record.getQrCodeTicketUnionpay()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setQrCodeSubTotal(transform(record.getQrCodeSubTotal()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setFaceEleBank(transform(record.getFaceEleBank()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setQrConnectivityAlipay(transform(record.getQrConnectivityAlipay()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setQrConnectivityWechat(transform(record.getQrConnectivityWechat()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setQrConnectivitySubTotal(transform(record.getQrConnectivitySubTotal()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setAllOneTrafficCard(transform(record.getAllOneTrafficCard()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setStationTicketLongCash(transform(record.getStationTicketLongCash()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setStationTicketShortCash(transform(record.getStationTicketShortCash()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setStationCompensationCash(transform(record.getStationCompensationCash()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setReleasePettyCash(transform(record.getReleasePettyCash()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setSubTotalPos(transform(record.getSubTotalPos()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
				revenueManagementDTO.setSettlementAmount(transform(record.getSettlementAmount()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                revenueManagementDTO.setSubTotal(transform(record.getSubTotal()).divide(decimal100,2,BigDecimal.ROUND_HALF_UP));
                list.add(revenueManagementDTO);

                //计算合计
                sumMoney.setTvmOneTicketCash(ifNullDecimal(sumMoney.getTvmOneTicketCash()).add(revenueManagementDTO.getTvmOneTicketCash()));
                sumMoney.setTvmOneTicketAlipay(ifNullDecimal(sumMoney.getTvmOneTicketAlipay()).add(revenueManagementDTO.getTvmOneTicketAlipay()));
                sumMoney.setTvmOneTicketWechat(ifNullDecimal(sumMoney.getTvmOneTicketWechat()).add(revenueManagementDTO.getTvmOneTicketWechat()));
                sumMoney.setTvmOneTicketXbank(ifNullDecimal(sumMoney.getTvmOneTicketXbank()).add(revenueManagementDTO.getTvmOneTicketXbank()));
                sumMoney.setTvmSubTotal(ifNullDecimal(sumMoney.getTvmSubTotal()).add(revenueManagementDTO.getTvmSubTotal()));

                sumMoney.setBomOneTicketCash(ifNullDecimal(sumMoney.getBomOneTicketCash()).add(revenueManagementDTO.getBomOneTicketCash()));
				sumMoney.setBomOnePosAmount(ifNullDecimal(sumMoney.getBomOnePosAmount()).add(revenueManagementDTO.getBomOnePosAmount()));
                sumMoney.setBomOneTicketPos(ifNullDecimal(sumMoney.getBomOneTicketPos()).add(revenueManagementDTO.getBomOneTicketPos()));
                sumMoney.setBomOneTicketWechat(ifNullDecimal(sumMoney.getBomOneTicketWechat()).add(revenueManagementDTO.getBomOneTicketWechat()));
                sumMoney.setBomSubTotal(ifNullDecimal(sumMoney.getBomSubTotal()).add(revenueManagementDTO.getBomSubTotal()));
                
				sumMoney.setPrefabricatedTicketAmount(ifNullDecimal(sumMoney.getPrefabricatedTicketAmount()).add(revenueManagementDTO.getPrefabricatedTicketAmount()));
				sumMoney.setPrefabricatedTicketPosAmount(ifNullDecimal(sumMoney.getPrefabricatedTicketPosAmount()).add(revenueManagementDTO.getPrefabricatedTicketPosAmount()));
                
				sumMoney.setEmergencyTicketAmount(ifNullDecimal(sumMoney.getEmergencyTicketAmount()).add(revenueManagementDTO.getEmergencyTicketAmount()));
                sumMoney.setTicketCounting(ifNullDecimal(sumMoney.getTicketCounting()).add(revenueManagementDTO.getTicketCounting()));
                sumMoney.setDailyTicketCash(ifNullDecimal(sumMoney.getDailyTicketCash()).add(revenueManagementDTO.getDailyTicketCash()));
                sumMoney.setDailyTicketPosAmount(ifNullDecimal(sumMoney.getDailyTicketPosAmount()).add(revenueManagementDTO.getDailyTicketPosAmount()));
				sumMoney.setDailyTicketPos(ifNullDecimal(sumMoney.getDailyTicketPos()).add(revenueManagementDTO.getDailyTicketPos()));
                sumMoney.setDailyTicketWechat(ifNullDecimal(sumMoney.getDailyTicketWechat()).add(revenueManagementDTO.getDailyTicketWechat()));
                sumMoney.setDailySubTotal(ifNullDecimal(sumMoney.getDailySubTotal()).add(revenueManagementDTO.getDailySubTotal()));
                sumMoney.setCommemorativeTicketCash(ifNullDecimal(sumMoney.getCommemorativeTicketCash()).add(revenueManagementDTO.getCommemorativeTicketCash()));
				sumMoney.setCommemorativeTicketPosAmount(ifNullDecimal(sumMoney.getCommemorativeTicketPosAmount()).add(revenueManagementDTO.getCommemorativeTicketPosAmount()));
                sumMoney.setCommemorativeTicketPos(ifNullDecimal(sumMoney.getCommemorativeTicketPos()).add(revenueManagementDTO.getCommemorativeTicketPos()));
                sumMoney.setCommemorativeTicketWechat(ifNullDecimal(sumMoney.getCommemorativeTicketWechat()).add(revenueManagementDTO.getCommemorativeTicketWechat()));
                sumMoney.setCommemorativeTicketSubTotal(ifNullDecimal(sumMoney.getCommemorativeTicketSubTotal()).add(revenueManagementDTO.getCommemorativeTicketSubTotal()));
                sumMoney.setAppCommemorativeTicketWechat(ifNullDecimal(sumMoney.getAppCommemorativeTicketWechat()).add(revenueManagementDTO.getAppCommemorativeTicketWechat()));
               
				sumMoney.setCatTicketCash(ifNullDecimal(sumMoney.getCatTicketCash()).add(revenueManagementDTO.getCatTicketCash()));
				sumMoney.setCatTicketPosAmount(ifNullDecimal(sumMoney.getCatTicketPosAmount()).add(revenueManagementDTO.getCatTicketPosAmount()));
                sumMoney.setCatTicketPos(ifNullDecimal(sumMoney.getCatTicketPos()).add(revenueManagementDTO.getCatTicketPos()));
                sumMoney.setCatTicketWechat(ifNullDecimal(sumMoney.getCatTicketWechat()).add(revenueManagementDTO.getCatTicketWechat()));
                sumMoney.setCatTicketTvmsimAlipay(ifNullDecimal(sumMoney.getCatTicketTvmsimAlipay()).add(revenueManagementDTO.getCatTicketTvmsimAlipay()));
                sumMoney.setCatTicketTvmsimWechat(ifNullDecimal(sumMoney.getCatTicketTvmsimWechat()).add(revenueManagementDTO.getCatTicketTvmsimWechat()));
                sumMoney.setCatTicketTvmsimXbank(ifNullDecimal(sumMoney.getCatTicketTvmsimXbank()).add(revenueManagementDTO.getCatTicketTvmsimXbank()));
                sumMoney.setCatSubTotal(ifNullDecimal(sumMoney.getCatSubTotal()).add(revenueManagementDTO.getCatSubTotal()));
                sumMoney.setCatTicketPayCard(ifNullDecimal(sumMoney.getCatTicketPayCard()).add(revenueManagementDTO.getCatTicketPayCard()));
                sumMoney.setOnlineTicketSales(ifNullDecimal(sumMoney.getOnlineTicketSales()).add(revenueManagementDTO.getOnlineTicketSales()));
                sumMoney.setQrCodeTicketAlipay(ifNullDecimal(sumMoney.getQrCodeTicketAlipay()).add(revenueManagementDTO.getQrCodeTicketAlipay()));
                sumMoney.setQrCodeTicketWechat(ifNullDecimal(sumMoney.getQrCodeTicketWechat()).add(revenueManagementDTO.getQrCodeTicketWechat()));
                sumMoney.setQrCodeTicketUnionpay(ifNullDecimal(sumMoney.getQrCodeTicketUnionpay()).add(revenueManagementDTO.getQrCodeTicketUnionpay()));
                sumMoney.setQrCodeSubTotal(ifNullDecimal(sumMoney.getQrCodeSubTotal()).add(revenueManagementDTO.getQrCodeSubTotal()));
                sumMoney.setFaceEleBank(ifNullDecimal(sumMoney.getFaceEleBank()).add(revenueManagementDTO.getFaceEleBank()));
                sumMoney.setQrConnectivityAlipay(ifNullDecimal(sumMoney.getQrConnectivityAlipay()).add(revenueManagementDTO.getQrConnectivityAlipay()));
                sumMoney.setQrConnectivityWechat(ifNullDecimal(sumMoney.getQrConnectivityWechat()).add(revenueManagementDTO.getQrConnectivityWechat()));
                sumMoney.setQrConnectivitySubTotal(ifNullDecimal(sumMoney.getQrConnectivitySubTotal()).add(revenueManagementDTO.getQrConnectivitySubTotal()));
                sumMoney.setAllOneTrafficCard(ifNullDecimal(sumMoney.getAllOneTrafficCard()).add(revenueManagementDTO.getAllOneTrafficCard()));
                sumMoney.setStationTicketLongCash(ifNullDecimal(sumMoney.getStationTicketLongCash()).add(revenueManagementDTO.getStationTicketLongCash()));
                sumMoney.setStationTicketShortCash(ifNullDecimal(sumMoney.getStationTicketShortCash()).add(revenueManagementDTO.getStationTicketShortCash()));
                sumMoney.setStationCompensationCash(ifNullDecimal(sumMoney.getStationCompensationCash()).add(revenueManagementDTO.getStationCompensationCash()));
                sumMoney.setReleasePettyCash(ifNullDecimal(sumMoney.getReleasePettyCash()).add(revenueManagementDTO.getReleasePettyCash()));
                sumMoney.setSubTotalPos(ifNullDecimal(sumMoney.getSubTotalPos()).add(revenueManagementDTO.getSubTotalPos()));
				sumMoney.setSettlementAmount(ifNullDecimal(sumMoney.getSettlementAmount()).add(revenueManagementDTO.getSettlementAmount()));
                sumMoney.setSubTotal(ifNullDecimal(sumMoney.getSubTotal()).add(revenueManagementDTO.getSubTotal()));

            }
            list.add(sumMoney);
            InputStream excelTemplateIs = null;
            try {
                response.reset(); // 非常重要
                response.setContentType("application/vnd.ms-excel");
                response.setCharacterEncoding("utf-8");
                final String fileName = URLEncoder.encode("票务收入日报表（14号线机场段）", "UTF-8");
                response.setHeader("Content-disposition", "attachment;filename=" + fileName + System.currentTimeMillis() + ".xlsx");

                // 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替
                // {} 代表普通变量 {.} 代表是list的变量
                excelTemplateIs = this.getClass().getResourceAsStream("/static/excel/template/export/SwCkOthenTicketRevenueManagementExcelTemplate.xlsx");

                ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).registerConverter(new LocalDateTimeConverter()).registerConverter(new LocalDateConverter()).withTemplate(excelTemplateIs).build();
                WriteSheet writeSheet = EasyExcel.writerSheet("票务收入日报表（14号线机场段）").build();
                // 这里注意 入参用了forceNewRow 代表在写入list的时候不管list下面有没有空行 都会创建一行，然后下面的数据往后移动。默认 是false，会直接使用下一行，如果没有则创建。
                // forceNewRow 如果设置了true,有个缺点 就是他会把所有的数据都放到内存了，所以慎用
                // 简单的说 如果你的模板有list,且list不是最后一行，下面还有数据需要填充 就必须设置 forceNewRow=true 但是这个就会把所有数据放到内存 会很耗内存
                // 如果数据量大 list不是最后一行 参照另一个
                FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.FALSE).build();
                excelWriter.fill(list, fillConfig, writeSheet);
                excelWriter.finish();

            } catch (Exception e) {
                e.printStackTrace();
                LOGGER.error("导出票务收入日报表（14号线机场段）异常");
            } finally {
                if(excelTemplateIs != null){
                    try {
                        excelTemplateIs.close();
                    } catch (IOException ioe) {
                        ioe.printStackTrace();
                    }
                }
            }
        }
    }

    //金额转换
    private BigDecimal transform(Long money) {
        return new BigDecimal(String.valueOf(money));
    }


    /**
     * 校验null
     * @param amount
     * @return
     */
    private BigDecimal ifNullDecimal(BigDecimal amount) {
        if(amount == null){
            return new BigDecimal("0");
        }
        return amount;
    }

}
